import TitleText from "./TitleText/index.vue";
import CustomImage from "./CustomImage/index.vue";
import CustomCard from "./CustomCard/index.vue";
import CustomBanner from "./CustomBanner/index.vue";
import CustomDialog from "./CustomDialog/index.vue";

const COMPONENT_LIST = [
  { title: "标题文本", component: TitleText },
  { title: "图片（支持热区）", component: CustomImage },
  { title: "用户信息栏", component: CustomCard },
  { title: "轮播图", component: CustomBanner },
  { title: "弹窗", component: CustomDialog },
];

const install = (Vue) => {
  if (install.installed) return;
  COMPONENT_LIST.map(({ component }) => {
    console.log(component);
    return Vue.component(component.props.name, component);
  });
};

if (typeof window !== "undefined" && window.Vue) {
  install(window.Vue);
}

export { TitleText, COMPONENT_LIST };

export default {
  install,
  TitleText,
  CustomCard,
  CustomBanner,
};
